qinglan.Canvas.ParBulletModel = qinglan.Canvas.ParticleModel.extend(function(id, opt){

}).methods({
	update: function(bullet){
		var distance = bullet.distance;
		var theta = bullet.theta; 
		var x = distance * Math.cos(theta) + bullet.initPosition.x;
		var y = distance * Math.sin(theta) + bullet.initPosition.y;
		bullet.position = new qinglan.Canvas.Vector2(x, y);

		//qinglan.Debug.info('distance : ['+distance+'] theta : [+'+theta+'] x : ['+x+']  y: ['+ y+'] init.x: [' +bullet.getStyle('initPosition.x')+'] init.y: [' +bullet.getStyle('initPosition.y')+ ']' );
		
		if(bullet.isRotate){
			var p = bullet.position;
			var lp = bullet.lastPosition;
			var v = 0;
			var dx = p.x - lp.x;
			if(!(0 == dx)){
				v = (p.y - lp.y) / dx;
				var d = qinglan.Canvas.Const.rad2deg(Math.atan(v));
				0 > d && ( d += 180 );
				bullet.rotation = d;
			}
		}
		//qinglan.Debug.info(bullet.id + '  ' +bullet.position.x + ' ' + bullet.lastPosition.x+' ' +d);
	}
}).statics({
	createInstance: function(opt){
		var instance = qinglan.Canvas.ParBulletModel._instance
		if(!instance){
			instance = qinglan.Canvas.ParBulletModel._instance = new qinglan.Canvas.ParBulletModel('ParBulletModel', opt || {});
		}
		return instance;
	},
	_instance: null
})
